package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.cloud.netflix.zuul.filters.discovery.PatternServiceRouteMapper;
import org.springframework.context.annotation.Bean;

import com.example.demo.filter.ShenxdFilterProcessor;
import com.netflix.zuul.FilterProcessor;

@EnableZuulProxy
@SpringBootApplication
public class ApiGatewayApplication {

	public static void main(String[] args) {
		//扩展zuul过滤器的处理逻辑
		FilterProcessor.setProcessor(new ShenxdFilterProcessor());
		SpringApplication.run(ApiGatewayApplication.class, args);
	}
	
	
	
	//修改默认的为微服务创建的路由匹配规则
	@Bean
	public PatternServiceRouteMapper patternServiceRouteMapper(){
		return new PatternServiceRouteMapper("(?<name>^.+)-(?<version>v.+$)", "/${version}/${name}");
	}
	
}
